package com.hello;

import java.util.ArrayList;

import com.hello.resources.ContactInfo;

//a class representing the data we collected from the settings
public class DrunkoidSettingData {

	public ArrayList<String> numbersToBlock;
	public final String CASTLE = "*2400";

	private static DrunkoidSettingData instance;
	private ContactInfo smsContact=null;
	private String taxiPhone = CASTLE;
	private String myStreet = "";
	private String myCity = "";

	private DrunkoidSettingData(){
		numbersToBlock = new ArrayList<String>();
	}
	public static DrunkoidSettingData getInstance(){
		if (instance == null){
			instance = new DrunkoidSettingData();
		}
		return instance;
	}

	public boolean blockListontainsPhone(String phoneNumber){
		boolean res = false;
		for (String s : this.numbersToBlock){
			int from = s.lastIndexOf(" ");
			if (from != -1) {
				String currentPhone = s.substring(from + 1);
				if (phoneNumber!=null && phoneNumber.equals(currentPhone)){
					return true;
				}
			}
		}
		return res;
	}

	public String getMyStreet() {
		return myStreet;
	}
	public void setMyStreet(String myStreet) {
		this.myStreet = myStreet;
	}
	public String getMyCity() {
		return myCity;
	}
	public void setMyCity(String myCity) {
		this.myCity = myCity;
	}

	public String getTaxiPhone() {
		return taxiPhone;
	}
	public void setTaxiPhone(String taxiPhone) {
		this.taxiPhone = taxiPhone;
	}
	public ContactInfo getSmsContact(){
		return this.smsContact;
	}

	public void setSmsContact(ContactInfo contact){
		this.smsContact = contact;
	}

	public void clearBlockList(){
		this.numbersToBlock = new ArrayList<String>();
	}

	public ArrayList<String> getBlockList(){
		return this.numbersToBlock;
	}

	public void removeContactFromBlockList(int position){
		this.numbersToBlock.remove(position);
	}	

}
